{% extends 'dcim/module/base.html' %}
{% load helpers %}
{% load static %}

{% block drawer %}
    {% table_config_form rearport_table %}
{% endblock %}

{% block content %}
    <form method="post">
        {% csrf_token %}
        <div class="card">
            <div class="card-header">
                <strong>Rear Ports</strong>
            </div>
            {% include 'responsive_table.html' with table=rearport_table %}
            <div class="card-footer d-print-none">
                {% if perms.dcim.change_rearport %}
                    <button type="submit" name="_rename" formaction="{% url 'dcim:rearport_bulk_rename' %}?return_url={% url 'dcim:module_rearports' pk=object.pk %}" class="btn btn-warning btn-sm">
                        <span class="mdi mdi-rename" aria-hidden="true"></span> Rename
                    </button>
                    <button type="submit" name="_edit" formaction="{% url 'dcim:rearport_bulk_edit' %}?module={{ object.pk }}&return_url={% url 'dcim:module_rearports' pk=object.pk %}" class="btn btn-warning btn-sm">
                        <span class="mdi mdi-pencil" aria-hidden="true"></span> Edit
                    </button>
                    <button type="submit" name="_disconnect" formaction="{% url 'dcim:rearport_bulk_disconnect' %}?return_url={% url 'dcim:module_rearports' pk=object.pk %}" class="btn btn-danger btn-sm">
                        <span class="mdi mdi-ethernet-cable-off" aria-hidden="true"></span> Disconnect
                    </button>
                {% endif %}
                {% if perms.dcim.delete_rearport %}
                    <button type="submit" formaction="{% url 'dcim:rearport_bulk_delete' %}?return_url={% url 'dcim:module_rearports' pk=object.pk %}" class="btn btn-danger btn-sm">
                        <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete
                    </button>
                {% endif %}
                {% if perms.dcim.add_rearport %}
                    <div class="float-end">
                        <a href="{% url 'dcim:rearport_add' %}?module={{ object.pk }}&return_url={% url 'dcim:module_rearports' pk=object.pk %}" class="btn btn-primary btn-sm">
                            <span class="mdi mdi-plus-thick" aria-hidden="true"></span> Add rear ports
                        </a>
                    </div>
                {% endif %}
                <div class="clearfix"></div>
            </div>
        </div>
    </form>
{% endblock content %}

{% block javascript %}
    {{ block.super }}
    <script src="{% versioned_static 'js/connection_toggles.js' %}"></script>
    <script src="{% versioned_static 'js/tableconfig.js' %}"></script>
{% endblock javascript %}
